/**
 * Created by dengyuanke on 2018/3/28.
 */
new Vue({
    el:'#main-body',
    data:{
        artiscles:[],
        archives:[],
        categories:[],
        current:1,
        pageTotal:0
    },
    mounted:function () {
        this.$nextTick(function () {
            this.initView();
        })
    },
    filters:{
      formatDate:function (value) {
          return moment(value).format('YYYY/MM/DD');
      }
    },
    computed: {

    },
    methods: {
        initView:function () {
            var _this=this;
            axios.get(url+'artiscles', {
                params: {
                    current: _this.current,
                }
                }).then(function (response) {
                    _this.artiscles=response.data.result;
                    _this.pageTotal=response.data.totalSize;
                })
                .catch(function (error) {
                    console.log(error);
                });
        },
        archive:function (date) {
            let formatDate=moment(date).format('YYYYMM');
            window.location.href="full-width.html?type=archive&date="+formatDate;
        },
        archiveFormat:function (date) {
          let year=date.substring(0,date.indexOf("年"));
          let month=date.substring(date.indexOf("年")+1,date.indexOf("月"));
            window.location.href="full-width.html?type=archive&date="+year+month;
        },
        changePage:function (currentPage) {
            var _this=this;
            axios.get(url+'artiscles', {
                params: {
                    current: currentPage
                }
            }).then(function (response) {
                _this.artiscles=response.data.result;
                _this.pageTotal=response.data.totalSize;
            })
                .catch(function (error) {
                    console.log(error);
                });
        }

    }
}
);